// ml:run = $bin < input
#include <iostream>
#include <algorithm>
#include <cstring>
#include <unordered_map>

using ll = long long;
int const maxn = 50007;
ll a[maxn];
int n;
std::unordered_map<ll, int> count;

bool judge(ll mid)
{
    count.clear();
    for (int i = n - 1; i >= 0; i--) {
        ll t = a[i];
        while (t > mid) {
            if (t & 1) t--;
            t /= 2;
        }
        while (count[t] > 0 && t) {
            if (t & 1) t--;
            t /= 2;
        }
        if (!t) return false;
        count[t]++;
    }
    return true;
}

void print()
{
    for (auto & i : count)
        std::cout << i.first << " ";
    std::cout << "\n";
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin >> n;
    ll max = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        max = std::max(max, a[i]);
    }
    std::sort(a, a + n);
    ll l = n, r = max;
    while (l + 1 < r) {
        ll mid = (l + r) / 2;
        if (judge(mid)) r = mid;
        else l = mid;
    }
    if (judge(l)) r = l;
    judge(r);
    print();
}

